package distribuicaoDeProfessores;

/**
 *
 * @author Jaime
 */
public final class VerDisciplinas extends javax.swing.JPanel {
    /** Creates new form VerDisciplinas */
    public VerDisciplinas(Disciplinas disciplinas) {
        
        initComponents();
        atualizar(disciplinas);
    }
    
   /* public void remover(){
        for(int i = 0; i < modeloDisciplina.getRowCount(); i++)
            modeloDisciplina.removeRow(0);
    }*/
    public void atualizar(Disciplinas disciplinas){
        javax.swing.table.DefaultTableModel modeloDisciplina;
        String nomes[] = new String[3];
        modeloDisciplina = new javax.swing.table.DefaultTableModel();
        modeloDisciplina.addColumn("Indice");
        modeloDisciplina.addColumn("Nome");
        modeloDisciplina.addColumn("Periodo");
        
        java.text.DecimalFormat format = new java.text.DecimalFormat("000000");
        
       // for(int i = 0; i < disciplinas.getDisciplinas().size(); i++)
         //   remover();
        
        for(int i = 0; i < disciplinas.getDisciplinas().size(); i++){
            nomes[0]= format.format(i);
            nomes[1]= disciplinas.getDisciplinas().get(i).getNome();
            nomes[2]= ""+disciplinas.getDisciplinas().get(i).getPeriodo();
            modeloDisciplina.addRow(nomes);
        }
        tabela.setModel(modeloDisciplina);
    this.repaint();
    }   
  
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        tabela = new javax.swing.JTable();
        jLabel1 = new javax.swing.JLabel();

        setBackground(new java.awt.Color(255, 255, 204));
        setLayout(new java.awt.BorderLayout());

        tabela.setBackground(new java.awt.Color(255, 255, 153));
        tabela.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        tabela.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        tabela.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null}
            },
            new String [] {
                "Código", "Nome", "Periodo"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tabela.setToolTipText("");
        tabela.setEditingColumn(0);
        tabela.setEditingRow(0);
        tabela.setGridColor(new java.awt.Color(255, 153, 0));
        tabela.setName("Disciplinas Cadastradas"); // NOI18N
        tabela.setRowHeight(25);
        tabela.setSelectionBackground(new java.awt.Color(204, 255, 255));
        tabela.setSelectionForeground(new java.awt.Color(0, 0, 0));
        jScrollPane1.setViewportView(tabela);
        tabela.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);
        tabela.getColumnModel().getColumn(0).setResizable(false);
        tabela.getColumnModel().getColumn(2).setResizable(false);
        tabela.getAccessibleContext().setAccessibleName("Disciplias Cadastradas");

        add(jScrollPane1, java.awt.BorderLayout.CENTER);

        jLabel1.setFont(new java.awt.Font("Script MT Bold", 0, 36)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(255, 204, 0));
        jLabel1.setText("Todas as Disciplinas");
        add(jLabel1, java.awt.BorderLayout.PAGE_START);
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable tabela;
    // End of variables declaration//GEN-END:variables

}
